﻿Imports System.Collections.Generic
Imports MetodosComuns
Partial Class noticias_listarNoticiasPesquisaSimples
    Inherits System.Web.UI.Page

    Protected Sub btnPesquisar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPesquisar.Click
        Session("strFiltro") = txtBusca.Text
        Response.Redirect("listarNoticiasPesquisaSimples.aspx")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            If Session("strFiltro") Is Nothing Then
                Response.Redirect(TELA_LOGOUT)
            End If

            Dim strFiltro As String = Session("strFiltro")
            Dim lstBENoticia As List(Of extranet.BE.Noticia)

            txtBusca.Text = strFiltro

            If strFiltro.Length <= 2 Then
                lblErro.Text = "Para realizer uma busca utilize no mínimo 3 caracteres."
                lblErro.Visible = True
                Accordion1.Visible = False
            Else
                lstBENoticia = extranet.BC.BCNoticia.PesquisarSimples(strFiltro)
                If lstBENoticia.Count = 0 Then
                    lblErro.Visible = True
                    lblErro.Text = "Nenhum resultado foi encontrado para esta busca."
                    Accordion1.Visible = False
                Else
                    lblErro.Visible = False
                    Accordion1.Visible = True
                    Accordion1.DataSource = lstBENoticia
                    Accordion1.DataBind()
                End If
            End If
        End If

    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Response.Redirect("listarNoticiasPesquisaAvancada.aspx")
    End Sub
End Class
